// import store from "../../store";
// import {openBrowser,openApp} from "../../utils/ZWY/utils";
// export default function(router) {
// 	router.beforeEach((to, from, next) => {
// 		console.log("即将要进入的路由", from.query);
// 		if(from.query.share) {
// 			 //用来校验微信的ua
// 			let ua = navigator.userAgent.toLowerCase();
// 			let isWeixin = ua.indexOf('micromessenger') != -1;
// 			if(isWeixin) {
// 				// document.querySelector(".container-box").onclick = function() {
// 					openBrowser()
// 				// }
// 			} else {
// 				// document.querySelector(".container-box").onclick = function() {
					
// 					let params = {type: "MyWebview", path: from.path ? from.path.slice(1) : ""}
// 					// alert(from.path.slice(1));
// 					openApp(params);
// 				// }
// 			}
// 			return
// 		}
// 		store.commit("setRouterLifeCycleOfName", {
// 			name: to.name
// 		});
// 		//清理editConfig
// 		store.commit("setEditConfigVuex", {});
// 		next();
// 	});
// }

import store from "../../store";
import {STYLE_PREFIX, REAL_PREFIX, EDIT_PREFIX} from "../../config/components/prefix";
import {initComponentsList} from "../../helper/drag-plugin/initComponents";
import {clearDataStoreForMemory} from "../lxn/handleData";
import {openBrowser,openApp} from "../../utils/ZWY/utils";
export default function(router) {
	router.beforeEach((to, from, next) => {
		clearDataStoreForMemory();
		console.log("即将要进入的路由", from.query, to);
		if(from.query.share) {
			//用来校验微信的ua
		   let ua = navigator.userAgent.toLowerCase();
		   let isWeixin = ua.indexOf('micromessenger') != -1;
		   if(isWeixin) {
				   openBrowser()
		   } else {
				   let params = {type: "MyWebview", path: from.path ? from.path.slice(1) : ""}
				   openApp(params);
		   }
		   return
	   }
		store.commit("setRouterLifeCycleOfName", {
			name: to.name
			// name:'s111534132'
		});
		//初始化当前页面该显示哪些组件
		_initComponents(to.name);
		// _initComponents('s111534132');
		//清理editConfig
		store.commit("setEditConfigVuex", {});
		next();
	});
}
function _initComponents(pageName) {
	console.log("_initComponents", pageName);
	//设置即将进入页面的组件列表
	initComponentsList();
}

